from demo.models import WebGLModel, Comment
#from demo.models import Comment
from django.http import Http404
from django.template import Context, loader
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponse

def index(request):
    demo_list = WebGLModel.objects.all().order_by('pub_date')[:5]
    t = loader.get_template('site/index.html')
    c = Context({
        'demo_list': demo_list,
    })
    return HttpResponse(t.render(c))
    
def info(request, id):
    return HttpResponse("Information about this project %s." % id)
    
def rep(request):
    information = "info"
    template = loader.get_template("site/rep.html")
    c = Context({
        'information': information,
    })
    return HttpResponse(template.render(c))
    
def detail(request, id):
    demo = WebGLModel.objects.get(pk=id)
    com = Comment.objects.all().order_by('com_date')[:5]
    t = loader.get_template('site/detail.html')
    c = Context({
        'demo': demo,
        'com': com,
    })
    return HttpResponse(t.render(c))
        
def written(request):
    null = "null"
    temp = loader.get_template('site/written.html')
    c = Context({
        'null': null,
    })
    return HttpResponse(temp.render(c))
    
def biblio(request):
    null = "null"
    tempp = loader.get_template('site/biblio.html')
    c = Context({
        'null': null,
    })
    return HttpResponse(tempp.render(c))
    